HOSTNAME=$(shell hostname)
IGRAPH_PFIX=$(shell if [ "${HOSTNAME}" = "ensibm" ]; then echo /home/ensi2a/huilleta/bin; else echo `pkg-config --libs-only-L igraph | sed -e 's/-L//' -e 's/lib//'`; fi)

IGRAPH_INCLUDE=${IGRAPH_PFIX}/include/igraph
IGRAPH_LIBS=-L${IGRAPH_PFIX}/lib -lm -ligraph

CC=gcc

OBJS=lists.o 
OBJS_MERITOUS=meritous/levelblit.o meritous/gamemap.o meritous/tiles.o mapgen/mapgen.o mapgen/mapgen_meritous.o evaluators/evalsize.o evaluators/evaldiff.o utils.o filler.o mapgen/gram_simple.o sizecomputations.o pointlessareas.o evaluators/evalfun.o viz_hooks.o

HEADERS=lists.h
CFLAGS=-W -Wall -O3 -g -I. -I.. -Imapgen -I${IGRAPH_INCLUDE} `sdl-config --cflags` -I/home/perms/wagnerf/libs/include/SDL
LDFLAGS=${IGRAPH_LIBS}

all: $(OBJS) viz

test_graph: ./evaluators/test_graph.o ./evaluators/evalsize.o utils.o
	${CC} -o test_graph ${CFLAGS} $^ ${LDFLAGS}

test_graph_diff: ./evaluators/test_graph_diff.o ./evaluators/evaldiff.o ./evaluators/evalsize.o utils.o
	${CC} -o test_graph_diff ${CFLAGS} $^ ${LDFLAGS}

test_graph_filler : test_graph_filler.o filler.o ./evaluators/evalsize.o ./evaluators/evaldiff.o utils.o
	${CC} -o test_graph_filler ${CFLAGS} $^ ${LDFLAGS}

test_graph_arbre : test.o
	${CC} -o test ${CFLAGS} $^ ${LDFLAGS}

viz: $(OBJS_MERITOUS)
	$(CC) -o $@ ${CFLAGS} $^ ${LDFLAGS} `sdl-config --libs` -lSDL_image -lz -L/home/perms/wagnerf/libs/lib 

$(OBJS) $(OBJS_MERITOUS):	%.o: %.c
	$(CC) -o $@ -c $< $(CFLAGS)

.PHONY clean: 
	rm -f ${OBJS} ${OBJS_MERITOUS} viz evaluators/*.o test_graph
